# Chip
URL: /lynx/components/chip
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/components/chip.mdx
A component that displays a short value that users can select or execute.
Lynx Engine 최소 버전: 3.6
사용 가능 버전: @seed-design/lynx-react@0.5.0, @seed-design/lynx-css@0.9.0
## Preview
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Button ChipToggle ChipRadio Chip 1Radio Chip 2
);
}
```
## Installation
- npm: npm install @seed-design/lynx-react @seed-design/lynx-css
- pnpm: pnpm add @seed-design/lynx-react @seed-design/lynx-css
- yarn: yarn add @seed-design/lynx-react @seed-design/lynx-css
- bun: bun add @seed-design/lynx-react @seed-design/lynx-css
Lynx `Chip` is provided directly from the `@seed-design/lynx-react` package without a separate `ui:chip` snippet.
## Props
### `Chip.Button`
### `Chip.Toggle`
### `Chip.RadioRoot`
### `Chip.RadioItem`
### Slots
## Examples
### Sizes
#### Small
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Small ButtonSmall ToggleSmall Radio 1Small Radio 2
);
}
```
#### Medium
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Medium ButtonMedium ToggleMedium Radio 1Medium Radio 2
);
}
```
#### Large
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Large ButtonLarge ToggleLarge Radio 1Large Radio 2
);
}
```
### Variants
#### Solid
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Solid ButtonSolid ToggleSolid Radio 1Solid Radio 2
);
}
```
#### Outline Strong
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Outline Strong ButtonOutline Strong ToggleOutline Strong Radio 1Outline Strong Radio 2
);
}
```
#### Outline Weak
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Outline Weak ButtonOutline Weak ToggleOutline Weak Radio 1Outline Weak Radio 2
);
}
```
### Prefix Icon
```tsx
import "./styles";
import IconHeartFill from "@karrotmarket/lynx-monochrome-icon/IconHeartFill";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
} />
With Icon Button} />
With Icon Toggle} />
With Icon Radio 1} />
With Icon Radio 2
);
}
```
### Suffix Icon
```tsx
import "./styles";
import IconChevronDownLine from "@karrotmarket/lynx-monochrome-icon/IconChevronDownLine";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
Button with Suffix} />
Toggle with Suffix} />
Radio with Suffix 1} />
Radio with Suffix 2} />
);
}
```
### Icon Only
With `layout="iconOnly"`, pass both `Icon` as a child and `accessibility-label`.
```tsx
import "./styles";
import IconArrowClockwiseCircularLine from "@karrotmarket/lynx-monochrome-icon/IconArrowClockwiseCircularLine";
import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine";
import IconBellSlashLine from "@karrotmarket/lynx-monochrome-icon/IconBellSlashLine";
import IconTimer_10Line from "@karrotmarket/lynx-monochrome-icon/IconTimer_10Line";
import IconTimer_3Line from "@karrotmarket/lynx-monochrome-icon/IconTimer_3Line";
import { useState } from "@lynx-js/react";
import { Chip, Icon, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [checked, setChecked] = useState(false);
return (
} />
: } />
} />
} />
);
}
```
### Prefix Avatar
The Lynx package does not provide an Avatar component. Use the `Chip.PrefixAvatar` slot by putting your app's own avatar component or view inside it. The initial circle in the example below is not an Avatar implementation including image loading and fallback, but only shows how to combine slots.
```tsx
import "./styles";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
function AppAvatar() {
return (
A
);
}
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
With Avatar ButtonWith Avatar ToggleWith Avatar Radio 1With Avatar Radio 2
);
}
```
### Listening to Value Changes
- `Chip.Toggle`
- You can detect toggle state changes with `onCheckedChange`.
- `Chip.RadioRoot` / `Chip.RadioItem`
- You can detect radio button value changes with `onValueChange` of `Chip.RadioRoot`.
```tsx
import "./styles";
import { useState } from "@lynx-js/react";
import { Chip, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [toggleCount, setToggleCount] = useState(0);
const [toggleLastValue, setToggleLastValue] = useState(null);
const [radioCount, setRadioCount] = useState(0);
const [radioLastValue, setRadioLastValue] = useState(null);
return (
{
setToggleCount((previous) => previous + 1);
setToggleLastValue(checked);
}}
>
Toggle Chip
onCheckedChange called: {toggleCount} times, last value:{" "}
{toggleLastValue === null ? "-" : JSON.stringify(toggleLastValue)}
{
setRadioCount((previous) => previous + 1);
setRadioLastValue(value);
}}
>
Radio 1Radio 2
onValueChange called: {radioCount} times, last value: {radioLastValue ?? "-"}
);
}
```
## Differences from Web Version
Lynx `Chip` uses the same Button, Toggle, Radio composition and size/variant names as React `Chip`, but has the following differences:
- **Rendering elements**: Native `` / `` are rendered instead of HTML `
## Lynx Unsupported Features
The following features are not supported due to differences in the current Lynx implementation and runtime model.
| Feature | Description |
| --------------------------------------- | --------------------------------------------------------------------------------------- |
| HiddenInput / `inputProps` | Lynx has no HTML input and form submission model. |
| `name` / `required` / native form value | There is no target to connect HTML form attributes. |
| raw DOM `onChange` | Replaced with `onCheckedChange` or `onValueChange`. |
| Keyboard focus / `focusVisible` | Lynx has no keyboard focus model like the web. |
| `asChild` | Lynx does not support web Slot-based polymorphic rendering. |
| Avatar package | Use by putting your app's own avatar view or component in the `Chip.PrefixAvatar` slot. |