ColorPicker
Genel görünümimport { ColorDot, ColorPicker, ColorSlider, ColorSpectrum } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Renk noktası
Bir örnek düğmesi. On palet rengi ya da value üzerinden herhangi bir CSS rengi. aria-label zorunludur — renkli bir dairenin kendine ait erişilebilir adı yoktur.
import { ColorDot } from "@nili/ui"
export function Example() {
const [selected, setSelected] = useState("blue")
return (
<>
{palette.map((color) => (
<ColorDot
key={color}
color={color}
aria-label={color}
selected={selected === color}
onClick={() => setSelected(color)}
/>
))}
{/* an arbitrary colour */}
<ColorDot value="#0E121B" aria-label="Ink" />
</>
)
}Renk seçici
Tayf, ton rayı ve bir onaltılık alan. defaultValue ile denetimsiz ya da value artı onChange ile denetimli — bu, saydamsızlık açıkken alfa çiftini de içeren bir onaltılık dizeyle tetiklenir.
#335CFFimport { ColorPicker } from "@nili/ui"
export function Example() {
const [color, setColor] = useState("#335CFF")
return <ColorPicker value={color} onChange={setColor} />
}Saydamsızlık ve örnekler
withOpacity alfa rayını ekler ve onaltılık alanı sekiz haneye geçirir. swatches, denetimlerin altındaki son kullanılan ya da marka renkleri satırıdır.
import { ColorPicker } from "@nili/ui"
export function Example() {
return (
<ColorPicker
withOpacity
defaultValue="#7D52F4CC"
swatches={["#335CFF", "#1FC16B", "#FB3748", "#F6B51E", "#7D52F4"]}
/>
)
}Alt bilgi ve etiketler
footer onaltılık alanın altında durur — seçici bir açılır katmandaysa genelde bir onay düğmesi. Görünen her dize bir prop’tur; bileşen kendi çeviri yığınını taşımaz.
import { ColorPicker, Button } from "@nili/ui"
export function Example() {
return (
<ColorPicker
withOpacity
defaultValue="#FB3748"
swatches={swatches}
labels={{
spectrum: "Saturation and brightness",
hue: "Hue",
opacity: "Opacity",
hex: "Hex value",
swatches: "Saved colours",
eyedropper: "Pick a colour from the screen",
}}
footer={<Button size="xs" fullWidth>Apply</Button>}
/>
)
}ColorDot
extends Omit< ComponentPropsWithoutRef<'button'>, 'color' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| color | gray | blue | orange | red | green | yellow | purple | sky | pink | teal | — | One of the ten palette colours, or a raw CSS colour via `value`. |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | Arbitrary colour. Wins over `color`. |
| defaultValue | string | — | |
| name | string | — | |
| aria-label* | string | — | Accessible name — a coloured circle has none. |
| selected | boolean | false |
ColorDotSwatch
dahiliColorPicker
extends Omit< ComponentPropsWithoutRef<'div'>, 'onChange' | 'defaultValue' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| value | string | — | Controlled hex, e.g. `'#335CFF'` or `'#335CFF80'`. |
| defaultValue | string | #335CFF | |
| onChange | (hex: string) => void | — | |
| withOpacity | boolean | true | Show the alpha track. |
| swatches | string[] | — | Swatch row under the controls. |
| footer | ReactNode | — | Rendered under the hex field — a confirm button, for instance. |
| labels | { format?: string; eyedropper?: string; spectrum?: string; hue?: string; opacity?: string; hex?: string; swatches?: string; } | — |
ColorSlider
extends Omit< ComponentPropsWithoutRef<'div'>, 'onChange' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| type | hue | opacity | hue |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| value* | number | — | |
| onChange* | (value: number) => void | — | |
| baseColor | string | #000 | For the opacity track, the colour the gradient fades to. |
| thumbColor | string | — | Fill of the thumb. Figma paints it with the picked colour. |
| label | string | — |
ColorSpectrum
extends Omit< ComponentPropsWithoutRef<'div'>, 'onChange' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| hue* | number | — | |
| saturation* | number | — | |
| brightness* | number | — | |
| onChange* | (next: { saturation: number; brightness: number }) => void | — | |
| label | string | Saturation and brightness |