import { useState } from "react" import type { Meta, StoryObj } from "@storybook/react-vite" import { BoldIcon, ItalicIcon, StarIcon } from "lucide-react" import { Toggle, ToggleGroup, ToggleGroupItem } from "@hm-design/ui" import { StateBoard } from "@/components/story-board" import { STORY_KICKER, StoryPage, StoryPageHeader, StorySection } from "@/components/story-page" // Toggle is a persistent pressed-state control. The representative Story shows each state with real, clickable toggles; the same // specimens also exist as Stories tagged `verification` (hidden from the sidebar). Icon-only toggles carry an `aria-label`. function OffOn() { return (
Off On Outline off Outline on
) } function WithIcon() { return (
즐겨찾기
) } function Sizes() { return (
{(["sm", "default", "lg"] as const).map((size) => (
즐겨찾기 {size}
))}
) } function Disabled() { return (
Disabled off Disabled on
) } function Controlled() { const [pressed, setPressed] = useState(false) return (
알림 {`pressed = ${String(pressed)}`}
) } // className extension: the consumer's width / rounded utilities win over the default look. function Extended() { return ( w-40 rounded-full ) } const sections = [ { id: "offon", label: "Off / On", node: }, { id: "icon", label: "Icon-only and icon + text", node: }, { id: "sizes", label: "Sizes", node: }, { id: "disabled", label: "Disabled", node: }, { id: "controlled", label: "Controlled", node: }, { id: "extended", label: "className extension", node: }, ] const meta = { title: "Components/Form/Toggle", component: Toggle, parameters: { layout: "padded" } } satisfies Meta export default meta type Story = StoryObj const board = (...ids: string[]) => ( ids.includes(s.id)).map((s) => ({ id: s.id, label: s.label, children: s.node }))} /> ) // Representative Story: the common Story page; the sections group the same specimens. export const All: Story = { name: "Toggle", parameters: { layout: "fullscreen", controls: { disable: true } }, render: () => ( {board("offon")}

단독 · 독립 선택

알림

연결 그룹 · 단일 선택

왼쪽가운데오른쪽

연결 그룹 · 다중 선택

굵게기울임
{board("icon")} {board("disabled", "controlled")} {board("extended")}
), } export const States: Story = { tags: ["verification"], render: () => } export const IconOnly: Story = { tags: ["verification"], name: "Icon Only", render: () => } export const DisabledToggle: Story = { tags: ["verification"], name: "Disabled", render: () => } export const ContentNodes: Story = { tags: ["verification"], render: () => (
{[]} <> <>즐겨찾기 즐겨찾기
), }