}
diff --git a/thaw/src/color_picker/color-picker.css b/thaw/src/color_picker/color-picker.css
index 15378ad0..18ccf705 100644
--- a/thaw/src/color_picker/color-picker.css
+++ b/thaw/src/color_picker/color-picker.css
@@ -28,6 +28,10 @@
height: 100%;
}
+.thaw-color-picker-trigger--disabled {
+ cursor: not-allowed;
+}
+
div.thaw-color-picker-popover {
width: 240px;
padding: var(--spacingVerticalM) var(--spacingHorizontalM);
diff --git a/thaw/src/color_picker/docs/mod.md b/thaw/src/color_picker/docs/mod.md
index d352c1c7..9925d486 100644
--- a/thaw/src/color_picker/docs/mod.md
+++ b/thaw/src/color_picker/docs/mod.md
@@ -46,10 +46,23 @@ view! {
}
```
+### Disabled
+
+```rust demo
+use palette::Srgb;
+
+let value = RwSignal::new(Color::from(Srgb::new(0.0, 0.0, 0.0)));
+
+view! {
+
+}
+```
+
### ColorPicker Props
-| Name | Type | Default | Desciption |
-| ----- | ------------------------- | ------------------------- | -------------------- |
-| class | `MaybeProp` | `Default::default()` | |
-| value | `Model` | `Default::default()` | Value of the picker. |
-| size | `Signal` | `ColorPickerSize::Medium` | Size of the picker. |
+| Name | Type | Default | Desciption |
+| -------- | ------------------------- | ------------------------- | ------------------------------------ |
+| class | `MaybeProp` | `Default::default()` | |
+| disabled | `Signal` | `false` | Whether to disable the color picker. |
+| value | `Model` | `Default::default()` | Value of the picker. |
+| size | `Signal` | `ColorPickerSize::Medium` | Size of the picker. |
diff --git a/thaw/src/color_picker/mod.rs b/thaw/src/color_picker/mod.rs
index 43b7d9e0..37192088 100644
--- a/thaw/src/color_picker/mod.rs
+++ b/thaw/src/color_picker/mod.rs
@@ -19,6 +19,9 @@ pub fn ColorPicker(
/// Size of the picker.
#[prop(optional, into)]
size: Signal,
+ /// Whether to disable the color picker.
+ #[prop(optional, into)]
+ disabled: Signal,
) -> impl IntoView {
mount_style("color-picker", include_str!("./color-picker.css"));
let hue = RwSignal::new(0f32);
@@ -104,6 +107,9 @@ pub fn ColorPicker(
let trigger_ref = NodeRef::::new();
let popover_ref = NodeRef::::new();
let show_popover = move |_| {
+ if disabled.get() {
+ return;
+ }
is_show_popover.set(true);
};
@@ -140,6 +146,7 @@ pub fn ColorPicker(
+}
+```
+
### DatePicker Props
| Name | Type | Default | Desciption |
| --- | --- | --- | --- |
| class | `MaybeProp` | `Default::default()` | |
| id | `MaybeProp` | `Default::default()` | |
+| disabled | `Signal` | `false` | Whether the date picker is disabled. |
| name | `MaybeProp` | `Default::default()` | A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. |
| rules | `Vec>` | `vec![]` | The rules to validate Field. |
| value | `OptionModel` | `Default::default()` | Set the date picker value. |
diff --git a/thaw/src/date_picker/mod.rs b/thaw/src/date_picker/mod.rs
index 11fd894c..d3c35b9a 100644
--- a/thaw/src/date_picker/mod.rs
+++ b/thaw/src/date_picker/mod.rs
@@ -18,6 +18,9 @@ use thaw_utils::{
pub fn DatePicker(
#[prop(optional, into)] class: MaybeProp,
#[prop(optional, into)] id: MaybeProp,
+ /// Whether the date picker is disabled.
+ #[prop(optional, into)]
+ disabled: Signal,
/// A string specifying a name for the input control.
/// This name is submitted along with the control's value when the form data is submitted.
#[prop(optional, into)]
@@ -92,6 +95,9 @@ pub fn DatePicker(
};
let open_panel = move || {
+ if disabled.get() {
+ return;
+ }
if is_show_panel.get() {
return;
}
@@ -112,6 +118,7 @@ pub fn DatePicker(
{locale.get().ab_month(month.number_from_month() as u8)}
+
+ {locale.get().ab_month(month.number_from_month() as u8)}
+
}
}
diff --git a/thaw/src/icon/icons/mod.rs b/thaw/src/icon/icons/mod.rs
index 40439c23..ea0c2712 100644
--- a/thaw/src/icon/icons/mod.rs
+++ b/thaw/src/icon/icons/mod.rs
@@ -32,8 +32,8 @@ pub fn ChevronRight12RegularIcon() -> impl IntoView {
>
-
+ fill="currentColor"
+ >
}
}
diff --git a/thaw/src/input/input.css b/thaw/src/input/input.css
index b3da1444..57cc45ff 100644
--- a/thaw/src/input/input.css
+++ b/thaw/src/input/input.css
@@ -166,6 +166,8 @@
cursor: not-allowed;
}
+.thaw-input--disabled > .thaw-input__prefix,
+.thaw-input--disabled > .thaw-input__suffix,
.thaw-input--disabled > .thaw-input__input::placeholder {
color: var(--colorNeutralForegroundDisabled);
}
diff --git a/thaw/src/popover/mod.rs b/thaw/src/popover/mod.rs
index 77ef719e..c8e6cc1b 100644
--- a/thaw/src/popover/mod.rs
+++ b/thaw/src/popover/mod.rs
@@ -167,7 +167,11 @@ where
on:mouseleave=on_mouse_leave
>
{children()}
-
+
diff --git a/thaw/src/radio/docs/mod.md b/thaw/src/radio/docs/mod.md
index bf61d8c9..f0470a39 100644
--- a/thaw/src/radio/docs/mod.md
+++ b/thaw/src/radio/docs/mod.md
@@ -24,6 +24,19 @@ view! {
}
```
+## Disabled
+
+RadioGroup can be disabled, which disables all Radio items inside.
+
+```rust demo
+view! {
+
+
+
+
+}
+```
+
### Radio Props
| Name | Type | Default | Description |
@@ -38,6 +51,7 @@ view! {
| --- | --- | --- | --- |
| class | `MaybeProp` | `Default::default()` | |
| id | `MaybeProp` | `Default::default()` | |
+| disabled | `Signal` | `false` | Disable all Radio items in this group. |
| name | `MaybeProp` | `Default::default()` | A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. |
| rules | `Vec` | `vec![]` | The rules to validate Field. |
| value | `OptionModel` | `Default::default()` | The selected Radio item in this group. |
diff --git a/thaw/src/radio/mod.rs b/thaw/src/radio/mod.rs
index 2e58cf07..35ef36f2 100644
--- a/thaw/src/radio/mod.rs
+++ b/thaw/src/radio/mod.rs
@@ -44,6 +44,7 @@ pub fn Radio(
class="thaw-radio__input"
type="radio"
id=id.clone()
+ disabled=group.disabled
name=group.name
value=item_value.get_value()
prop:checked=move || checked.get()
diff --git a/thaw/src/radio/radio.css b/thaw/src/radio/radio.css
index 509ce67b..5aecbdf1 100644
--- a/thaw/src/radio/radio.css
+++ b/thaw/src/radio/radio.css
@@ -50,11 +50,11 @@
color: var(--colorCompoundBrandForeground1);
}
-.thaw-radio__input:hover:checked ~ .thaw-radio__indicator {
+.thaw-radio__input:hover:checked:not(:disabled) ~ .thaw-radio__indicator {
color: var(--colorCompoundBrandForeground1Hover);
}
-.thaw-radio__input:hover:active ~ .thaw-radio__indicator {
+.thaw-radio__input:hover:active:not(:disabled) ~ .thaw-radio__indicator {
color: var(--colorCompoundBrandForeground1Pressed);
}
@@ -71,6 +71,11 @@
content: "";
}
+.thaw-radio__input:disabled ~ .thaw-radio__indicator {
+ border-color: var(--colorNeutralStrokeDisabled);
+ color: var(--colorNeutralForegroundDisabled);
+}
+
.thaw-radio__label {
margin-bottom: calc((16px - var(--lineHeightBase300)) / 2);
margin-top: calc((16px - var(--lineHeightBase300)) / 2);
@@ -100,3 +105,8 @@
.thaw-radio__input:enabled ~ .thaw-radio__label {
cursor: pointer;
}
+
+.thaw-radio__input:disabled ~ .thaw-radio__label {
+ color: var(--colorNeutralForegroundDisabled);
+ cursor: default;
+}
diff --git a/thaw/src/radio/radio_group.rs b/thaw/src/radio/radio_group.rs
index d65bc17e..c6f6138f 100644
--- a/thaw/src/radio/radio_group.rs
+++ b/thaw/src/radio/radio_group.rs
@@ -7,7 +7,12 @@ use thaw_utils::{class_list, OptionModel};
pub fn RadioGroup(
#[prop(optional, into)] class: MaybeProp,
#[prop(optional, into)] id: MaybeProp,
- #[prop(optional, into)] rules: Vec,
+ /// Disable all Radio items in this group.
+ #[prop(optional, into)]
+ disabled: Signal,
+ /// The rules to validate Field.
+ #[prop(optional, into)]
+ rules: Vec,
/// The selected Radio item in this group.
#[prop(optional, into)]
value: OptionModel,
@@ -32,7 +37,11 @@ pub fn RadioGroup(
});
view! {
-
+
{children()}
@@ -44,6 +53,7 @@ pub fn RadioGroup(
pub(crate) struct RadioGroupInjection {
pub value: OptionModel,
pub name: Signal,
+ pub disabled: Signal,
}
impl RadioGroupInjection {
diff --git a/thaw/src/slider/docs/mod.md b/thaw/src/slider/docs/mod.md
index acbcdc1c..ab19f9f7 100644
--- a/thaw/src/slider/docs/mod.md
+++ b/thaw/src/slider/docs/mod.md
@@ -31,6 +31,31 @@ view! {
}
```
+### Disabled
+
+A disabled slider will not change or fire events on click or keyboard press.
+
+```rust demo
+let value = RwSignal::new(0.0);
+
+view! {
+
+
+
+
+ "0"
+
+
+ "5"
+
+
+ "10"
+
+
+
+}
+```
+
## Slider Label
```rust demo
@@ -58,6 +83,7 @@ view! {
| class | `MaybeProp` | `Default::default()` | |
| style | `MaybeProp` | `Default::default()` | |
| id | `MaybeProp` | `Default::default()` | |
+| disabled | `Signal` | `false` | Whether the slider is disabled. |
| name | `MaybeProp` | `Default::default()` | A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. |
| rules | `Vec` | `vec![]` | The rules to validate Field. |
| value | `Model` | `0` | The current value of the controlled Slider. |
diff --git a/thaw/src/slider/docs/range-slider.md b/thaw/src/slider/docs/range-slider.md
index 78d35969..d3873bf6 100644
--- a/thaw/src/slider/docs/range-slider.md
+++ b/thaw/src/slider/docs/range-slider.md
@@ -34,13 +34,36 @@ view! {
}
```
+### Disabled
+
+```rust demo
+let value = RwSignal::new((6.0, 8.0));
+
+view! {
+
+
+
+
+ "0"
+
+
+ "5"
+
+
+ "10"
+
+
+
+}
+```
+
### SliderLabel
```rust demo
let value = RwSignal::new((0.0, 1.0));
view! {
-
+
"0"
@@ -60,6 +83,7 @@ view! {
| --- | --- | --- | --- |
| class | `MaybeProp` | `Default::default()` | |
| style | `MaybeProp` | `Default::default()` | |
+| disabled | `Signal` | `false` | Whether the slider is disabled. |
| value | `Model<(f64, f64)>` | `(0.0, 0.0)` | The current value of the controlled Slider. |
| min | `Signal` | `0` | Min value of the slider. |
| max | `Signal` | `100` | Max value of the slider. |
diff --git a/thaw/src/slider/range_slider/mod.rs b/thaw/src/slider/range_slider/mod.rs
index f67d3b9f..521d291e 100644
--- a/thaw/src/slider/range_slider/mod.rs
+++ b/thaw/src/slider/range_slider/mod.rs
@@ -7,7 +7,12 @@ use thaw_utils::{class_list, mount_style, Model};
pub fn RangeSlider(
#[prop(optional, into)] class: MaybeProp,
#[prop(optional, into)] style: MaybeProp,
- #[prop(optional, into)] value: Model<(f64, f64)>,
+ /// Whether the slider is disabled.
+ #[prop(optional, into)]
+ disabled: Signal,
+ /// The current value of the controlled Slider.
+ #[prop(optional, into)]
+ value: Model<(f64, f64)>,
/// Min value of the slider.
#[prop(default = 0f64.into(), into)]
min: Signal,
@@ -111,6 +116,9 @@ pub fn RangeSlider(
};
let on_click = move |e: web_sys::MouseEvent| {
+ if disabled.get() {
+ return;
+ }
if let Some(rail_el) = rail_ref.get_untracked() {
let min = min.get_untracked();
let max = max.get_untracked();
@@ -210,11 +218,17 @@ pub fn RangeSlider(
};
let on_left_mousedown = move |_| {
+ if disabled.get() {
+ return;
+ }
left_mousemove.set_value(true);
on_mousemove();
};
let on_right_mousedown = move |_| {
+ if disabled.get() {
+ return;
+ }
right_mousemove.set_value(true);
on_mousemove();
};
@@ -225,6 +239,7 @@ pub fn RangeSlider(
,
#[prop(optional, into)] style: MaybeProp,
#[prop(optional, into)] id: MaybeProp,
+ /// Whether the slider is disabled.
+ #[prop(optional, into)]
+ disabled: Signal,
/// A string specifying a name for the input control.
/// This name is submitted along with the control's value when the form data is submitted.
#[prop(optional, into)]
@@ -106,12 +109,14 @@ pub fn Slider(
+
+
+
+}
+```
+
+### Label
+
+```rust demo
+let checked = RwSignal::new(false);
+
+view! {
+
+}
+```
+
### Switch Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| class | `MaybeProp` | `Default::default()` | |
| id | `MaybeProp` | `Default::default()` | |
+| disabled | `Signal` | `false` | Whether to disable the switch. |
| name | `MaybeProp` | `Default::default()` | A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. |
| value | `MaybeProp` | `Default::default()` | A string specifying the value for the input control. |
| rules | `Vec` | `vec![]` | The rules to validate Field. |
diff --git a/thaw/src/switch/mod.rs b/thaw/src/switch/mod.rs
index e1f5b14f..575e7c8e 100644
--- a/thaw/src/switch/mod.rs
+++ b/thaw/src/switch/mod.rs
@@ -7,6 +7,9 @@ use thaw_utils::{class_list, mount_style, Model};
pub fn Switch(
#[prop(optional, into)] class: MaybeProp,
#[prop(optional, into)] id: MaybeProp,
+ /// Whether to disable the switch.
+ #[prop(optional, into)]
+ disabled: Signal,
/// A string specifying a name for the input control.
/// This name is submitted along with the control's value when the form data is submitted.
#[prop(optional, into)]
@@ -48,6 +51,7 @@ pub fn Switch(
svg {
display: inline;
line-height: 0;
@@ -81,3 +98,8 @@
.thaw-switch__input:enabled:not(:checked) ~ .thaw-switch__label {
color: var(--colorNeutralForeground1);
}
+
+.thaw-switch__input:disabled ~ .thaw-switch__label {
+ cursor: default;
+ color: var(--colorNeutralForegroundDisabled);
+}
\ No newline at end of file
diff --git a/thaw/src/tag/docs/mod.md b/thaw/src/tag/docs/mod.md
index 04452195..c13dce9a 100644
--- a/thaw/src/tag/docs/mod.md
+++ b/thaw/src/tag/docs/mod.md
@@ -13,6 +13,21 @@ view! {
}
```
+### Disabled
+
+```rust demo
+view! {
+
+ "Disabled"
+
+
+ "Interaction Tag"
+
+
+
+}
+```
+
### Size
```rust demo
@@ -58,6 +73,7 @@ view! {
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| class | `MaybeProp` | `Default::default()` | |
+| disabled | `Option>` | `None` | Whether the tag is disabled. |
| size | `Option>` | `None` | Size of the tag. |
| dismissible | `Signal` | `false` | A Tag can be dismissible. |
| on_dismiss | `Option>` | `None` | Callback for when a tag is dismissed. |
@@ -66,11 +82,12 @@ view! {
### InteractionTag Props
-| Name | Type | Default | Description |
-| -------- | ------------------------- | -------------------- | ---------------- |
-| class | `MaybeProp` | `Default::default()` | |
-| size | `Option>` | `None` | Size of the tag. |
-| children | `Children` | | |
+| Name | Type | Default | Description |
+| -------- | ------------------------- | -------------------- | ---------------------------------------- |
+| class | `MaybeProp` | `Default::default()` | |
+| disabled | `Option>` | `None` | Whether the interaction tag is disabled. |
+| size | `Option>` | `None` | Size of the tag. |
+| children | `Children` | | |
### InteractionTagPrimary Props
diff --git a/thaw/src/tag/docs/tag_group/mod.md b/thaw/src/tag/docs/tag_group/mod.md
index f2be81f7..598e414d 100644
--- a/thaw/src/tag/docs/tag_group/mod.md
+++ b/thaw/src/tag/docs/tag_group/mod.md
@@ -23,6 +23,20 @@ view! {
}
```
+### Disabled
+
+```rust demo
+view! {
+
+ "Tag 1"
+ "Tag 1"
+
+ "Tag 1"
+
+
+}
+```
+
### Sizes
```rust demo
@@ -51,6 +65,7 @@ view! {
| Name | Type | Default | Description |
| ----------- | -------------------------------- | -------------------- | ------------------------------------- |
| class | `MaybeProp` | `Default::default()` | |
+| disabled | `Signal` | `false` | Whether the tag group is disabled. |
| size | `Signal` | `TagSize::Medium` | Size of the tag. |
| dismissible | `Signal` | `false` | A Tag can be dismissible. |
| on_dismiss | `Option>` | `None` | Callback for when a tag is dismissed. |
diff --git a/thaw/src/tag/interaction-tag.css b/thaw/src/tag/interaction-tag.css
index af9359c3..d0819b01 100644
--- a/thaw/src/tag/interaction-tag.css
+++ b/thaw/src/tag/interaction-tag.css
@@ -51,6 +51,13 @@
background-color: var(--colorNeutralBackground3Pressed);
}
+.thaw-interaction-tag--disabled .thaw-interaction-tag-primary {
+ background-color: var(--colorNeutralBackgroundDisabled);
+ color: var(--colorNeutralForegroundDisabled);
+ border-color: var(--colorTransparentStrokeDisabled);
+ cursor: not-allowed;
+}
+
.thaw-interaction-tag-primary__primary-text {
grid-row-end: secondary;
grid-row-start: primary;
diff --git a/thaw/src/tag/interaction_tag.rs b/thaw/src/tag/interaction_tag.rs
index 8603f3f8..bb34797f 100644
--- a/thaw/src/tag/interaction_tag.rs
+++ b/thaw/src/tag/interaction_tag.rs
@@ -5,6 +5,9 @@ use thaw_utils::{class_list, mount_style};
#[component]
pub fn InteractionTag(
#[prop(optional, into)] class: MaybeProp,
+ /// Whether the interaction tag is disabled.
+ #[prop(optional, into)]
+ disabled: Option>,
/// Size of the tag.
#[prop(optional, into)]
size: Option>,
@@ -12,11 +15,22 @@ pub fn InteractionTag(
) -> impl IntoView {
mount_style("interaction-tag", include_str!("./interaction-tag.css"));
let tag_group = TagGroupInjection::use_context();
+
+ let disabled = {
+ if let Some(disabled) = disabled {
+ Some(disabled)
+ } else if let Some(tag_group) = &tag_group {
+ Some(tag_group.disabled.clone())
+ } else {
+ None
+ }
+ };
+
let size_class = {
if let Some(size) = size {
Some(size)
- } else if let Some(tag_group) = tag_group {
- Some(tag_group.size)
+ } else if let Some(tag_group) = &tag_group {
+ Some(tag_group.size.clone())
} else {
None
}
@@ -25,6 +39,7 @@ pub fn InteractionTag(
view! {