CompositionDisponible
Phosphor Icons
Las seis variantes de Phosphor con etiquetas accesibles e importación de los iconos utilizados.
Instalación
Agrega el componente y sus dependencias desde el registro que está ejecutándose en tu computadora.
terminal
npx shadcn@latest add https://brutallab.facilito.dev/r/icon.jsonUso
Importa el componente en tu proyecto y conserva el código bajo tu control.
tsx
"use client";
import { useState } from "react";
import {
HeartIcon,
GaugeIcon,
RepeatIcon,
KeyboardIcon,
SpeakerHighIcon,
StarIcon,
type IconWeight,
} from "@phosphor-icons/react";
import { Icon, iconWeights } from "@/components/ui/icon";
export default function Demo() {
const [weight, setWeight] = useState<IconWeight>("bold");
return (
<div className="grid gap-6">
<label className="flex items-center gap-3">
Weight / Variante
<select
aria-label="Icon weight"
value={weight}
onChange={(event) => setWeight(event.target.value as IconWeight)}
className="rounded border border-ink bg-card text-card-foreground p-2"
>
{iconWeights.map((value) => (
<option key={value}>{value}</option>
))}
</select>
</label>
<div className="flex flex-wrap gap-6">
{[HeartIcon, GaugeIcon, RepeatIcon, KeyboardIcon, SpeakerHighIcon, StarIcon].map(
(glyph, i) => (
<Icon key={i} icon={glyph} weight={weight} size={32} />
),
)}
</div>
<div className="flex flex-wrap gap-5">
{iconWeights.map((value) => (
<div key={value} className="grid justify-items-center gap-2">
<Icon icon={HeartIcon} weight={value} size={32} />
<span className="text-xs text-foreground">{value}</span>
</div>
))}
</div>
</div>
);
}
Estados e interacción
Aspecto, comportamiento y comprobación con teclado.
- Bold es el peso funcional predeterminado. Thin, light y regular para detalles; fill para selección; duotone para ilustración. No se altera stroke-width.
- Un icono decorativo no recibe foco. Su botón o enlace define hover, foco y nombre accesible.
Referencia API
Propiedades propias de BrutalLab. También acepta los atributos nativos correspondientes.
| Prop | Tipo | Default | Descripción |
|---|---|---|---|
| icon | Phosphor Icon | See example | Pass any icon imported from @phosphor-icons/react. |
| weight | thin | light | regular | bold | fill | duotone | bold | All six Phosphor weights. Bold is the functional default; no SVG stroke-width overrides. |
| size / color / mirrored / label | IconProps / string | See example | Size, color, mirroring and optional accessible label. |
Accesibilidad
Reglas que deben conservarse cuando el componente se adapte a un producto.
Los controles tienen etiquetas accesibles, foco visible y soporte de teclado.