You've already forked gpui-component
mirror of
https://github.com/librekeys/gpui-component.git
synced 2026-04-14 08:46:29 -07:00
## Summary
Add `color(impl Into<Hsla>)` builder method to `Switch`, allowing
callers to customize the background color when the switch is checked.
Defaults to `theme.primary` to preserve existing behavior.
```rust
Switch::new("id")
.checked(true)
.color(cx.theme().success) // green
Switch::new("id")
.checked(true)
.color(cx.theme().danger) // red
```
## Preview
<img width="676" height="104" alt="image"
src="https://github.com/user-attachments/assets/b1422295-e463-4075-b2f2-475c71ef7ac9"
/>
## Changes
- `crates/ui/src/switch.rs`: Add `color` field and builder method
- `crates/story/src/stories/switch_story.rs`: Add "Custom Color" section
- `docs/docs/components/switch.md`: Document `color` method
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>