Files
Floyd Wang f939cf8215 switch: Add color option for custom checked background (#2178)
## 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>
2026-03-25 13:56:28 +08:00
..
2026-01-12 22:31:40 +08:00
2026-01-12 22:31:40 +08:00
2026-01-12 22:31:40 +08:00

gpui-component-docs

To install dependencies:

bun install

To run:

bun run dev

This project was created using bun init in bun v1.2.23. Bun is a fast all-in-one JavaScript runtime.