diff --git a/package/component/src/component/tag/index.less b/package/component/src/component/tag/index.less index 4f001411..3bf6aaac 100644 --- a/package/component/src/component/tag/index.less +++ b/package/component/src/component/tag/index.less @@ -12,7 +12,7 @@ .layui-tag { display: inline-flex; - align-items: baseline; + align-items: center; vertical-align: middle; box-sizing: border-box; height: @tag-size-md; @@ -58,11 +58,17 @@ border-radius: 12px; } } -&-ellipsis { - white-space: nowwrap; - text-overflow: ellipsis; - overflow: hidden; -} + + &-ellipsis { + .layui-tag-text { + display: inline-block; + white-space: nowrap; + word-wrap: normal; + overflow: hidden; + text-overflow: ellipsis + } + + } &-size-lg { height: @tag-size-lg; diff --git a/package/component/src/component/tag/index.vue b/package/component/src/component/tag/index.vue index cd4490a4..b4770114 100644 --- a/package/component/src/component/tag/index.vue +++ b/package/component/src/component/tag/index.vue @@ -16,12 +16,13 @@ export interface LayTagProps { bordered?: boolean; disabled?: boolean; shape?: "square" | "round"; + maxWidth?: number | string; } const props = withDefaults(defineProps(), { color: "#EEE", size: "md", - shape: "square" + shape: "square", }); const emit = defineEmits(["close"]); @@ -36,7 +37,7 @@ const isCustomColor = computed( const visible = ref(true); const handleClose = (e: MouseEvent) => { - if(props.disabled) return; + if (props.disabled) return; //visible.value = false; emit("close", e); }; @@ -49,24 +50,30 @@ const classTag = computed(() => [ [`layui-bg-${props.color}`]: isBuiltInColor, "layui-tag-bordered": props.bordered, "layui-tag-disabled": props.disabled, + "layui-tag-ellipsis": props.maxWidth, }, ]); -const styleTag = computed(() => { - return isCustomColor.value ? { backgroundColor: props.color } : undefined; -}); +const styleTag = computed(() => [ + isCustomColor.value ? { backgroundColor: props.color } : {}, + { + "max-width": props.maxWidth ?? "unset" + }, +] +); + +