summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/tag.tsx
blob: c54e4d474794028225bb04bee292a86318341822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { type ComponentProps, splitProps } from "solid-js"

export interface TagProps extends ComponentProps<"span"> {
  size?: "normal" | "large"
}

export function Tag(props: TagProps) {
  const [split, rest] = splitProps(props, ["size", "class", "classList", "children"])
  return (
    <span
      {...rest}
      data-component="tag"
      data-size={split.size || "normal"}
      classList={{
        ...split.classList,
        [split.class ?? ""]: !!split.class,
      }}
    >
      {split.children}
    </span>
  )
}