Skip to content

Commit

Permalink
Merge pull request #408 from AnnMarieW/update-checkbox
Browse files Browse the repository at this point in the history
added custom icons to Checkbox
  • Loading branch information
AnnMarieW authored Nov 14, 2024
2 parents 91855e2 + 91e0c3e commit 961dff5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

# Unreleased

### Added

- Enabled custom icons in `Checkbox` Added `icon` and `indeterminateIcon` props #408 by @snehilvj

### Fixed
- In MultiSelect, enable the debounce to work when deleting items when the dropdown is closed when debounce is a number. #407 by @AnnMarieW
- In MultiSelect and Select, fixed regression where it was not possible to update both the value and data in the same callback #412


# 0.14.7

### Added
Expand Down
13 changes: 13 additions & 0 deletions src/ts/components/core/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ interface Props
checked?: boolean;
/** Whether component is disabled */
disabled?: boolean;
/** Icon */
icon?: React.ReactNode;
/** Indeterminate icon */
indeterminateIcon?: React.ReactNode;
}

/** Checkbox */
Expand All @@ -52,15 +56,24 @@ const Checkbox = (props: Props) => {
persistence,
persisted_props,
persistence_type,
icon,
indeterminateIcon,
...others
} = props;

const iconFunc = ({ indeterminate, ...others }) => {
const selected: any = indeterminate ? indeterminateIcon : icon;
Object.assign(selected.props._dashprivate_layout.props, others);
return selected;
};

return (
<MantineCheckbox
data-dash-is-loading={
(loading_state && loading_state.is_loading) || undefined
}
onChange={(ev) => setProps({ checked: ev.currentTarget.checked })}
icon={icon || indeterminateIcon ? iconFunc : undefined}
{...others}
/>
);
Expand Down

0 comments on commit 961dff5

Please sign in to comment.