Skip to content

Commit

Permalink
chore: update api
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra committed May 10, 2024
1 parent 79f7aa3 commit 9c3169e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/blade/src/components/DatePicker/_decisions/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,44 @@ type CalendarProps = {
};
```

## Examples

### Controlled DatePicker

```jsx
function ControlledDatePicker() {
const [selectedDate, setSelectedDate] = React.useState<DateValue>(new Date());

return (
<DatePicker
label="Pick date"
selectionType="single"
valueFormat="DD/MM/YYYY"
value={selectedDate}
onChange={setSelectedDate}
/>
);
}
```

### DatePicker Presets

```jsx
function DatePickerWithPresets() {
return (
<DatePicker
label="Pick date"
selectionType="range"
valueFormat="DD/MM/YYYY"
presets={[
{ label: 'Past 7 days', value: [dayjs().subtract(7, 'day'), dayjs()] },
{ label: 'Past month', value: [dayjs().subtract(1, 'month'), dayjs()] },
]}
/>
);
}
```

<details>

<summary>Alternative Approaches</summary>
Expand Down

0 comments on commit 9c3169e

Please sign in to comment.