ข้ามไปเนื้อหา
WhereUI

ค้นหาในเอกสาร

ค้นหาชื่อ component หรือหน้าเอกสาร

Marker

จาก shadcn

ข้อความกำกับแนวตั้ง เช่น หมายเหตุ คำอธิบายท้ายตาราง หรือหัวข้อคั่นกลางบรรทัด มีทั้งแบบเรียบ แบบเส้นคั่นสองข้าง และแบบเส้นใต้

หมายเหตุ: คำขอกู้หมดอายุใน 30 วันนับจากวันยื่น
ขั้นตอนถัดไป
ลงนามโดยผู้อนุมัติ: น้ำใจ ทรัพย์ดี

ติดตั้ง

Terminal
pnpm dlx shadcn@latest add @whereui/marker

ต้องผูก registry และติดตั้ง @whereui/theme นำหน้าเสมอเมื่อติดตั้งครั้งแรก

การใช้งาน

import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker"import { SparklesIcon } from "lucide-react"<Marker>  <MarkerIcon><SparklesIcon /></MarkerIcon>  <MarkerContent>หมายเหตุเล็ก ๆ</MarkerContent></Marker>

ข้อควรรู้

  • variant มี default, separator (เส้นคั่นซ้าย–ขวา เหมาะกับคำว่า หรือ) และ border (เส้นใต้)
  • MarkerIcon ซ่อนจากโปรแกรมอ่านหน้าจออัตโนมัติ (aria-hidden) เพราะเป็นการตกแต่ง

ซอร์สโค้ด

components/ui/marker.tsx
import * as React from "react"import { mergeProps } from "@base-ui/react/merge-props"import { useRender } from "@base-ui/react/use-render"import { cva, type VariantProps } from "class-variance-authority"import { cn } from "cn"const markerVariants = cva(  "group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground",  {    variants: {      variant: {        default: "",        separator:          "before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border",        border: "border-b border-border pb-2",      },    },  })function Marker({  className,  variant = "default",  render,  ...props}: useRender.ComponentProps<"div"> & VariantProps<typeof markerVariants>) {  return useRender({    defaultTagName: "div",    props: mergeProps<"div">(      {        className: cn(markerVariants({ variant, className })),      },      props    ),    render,    state: {      slot: "marker",      variant,    },  })}function MarkerIcon({ className, ...props }: React.ComponentProps<"span">) {  return (    <span      data-slot="marker-icon"      aria-hidden="true"      className={cn(        "size-4 shrink-0 [&_svg:not([class*='size-'])]:size-4",        className      )}      {...props}    />  )}function MarkerContent({ className, ...props }: React.ComponentProps<"span">) {  return (    <span      data-slot="marker-content"      className={cn(        "min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",        className      )}      {...props}    />  )}export { Marker, MarkerIcon, MarkerContent, markerVariants }