Skip to content

Commit b125801

Browse files
authored
Merge pull request #1476 from privy-open-source/feat/datepicker-placement
feat: create placement for datepicker
2 parents 1287780 + 1fda642 commit b125801

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/components/datepicker/Datepicker.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class="datepicker"
55
data-testid="datepicker"
66
aria-label="datepicker"
7+
:placement="placement"
78
:class="classNames"
89
:disabled="disabled">
910
<template #activator>
@@ -63,6 +64,7 @@ import type { CalendarMode } from '../calendar/adapter/adapter'
6364
import { useVModel } from '../input'
6465
import IconCalendar from '@privyid/persona-icon/vue/calendar/16.vue'
6566
import type { SizeVariant } from '../button'
67+
import type { Placement } from '@floating-ui/dom'
6668
6769
defineOptions({ inheritAttrs: false })
6870
@@ -139,6 +141,10 @@ const props = defineProps({
139141
type : String,
140142
default: undefined,
141143
},
144+
placement: {
145+
type : String as PropType<Placement>,
146+
default: 'bottom-start',
147+
},
142148
})
143149
144150
const emit = defineEmits<{

src/components/datepicker/index.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,37 @@ Datepicker has 4 variants size: `xs`, `sm`, `md`, `lg`, default is `md`.
5757
</template>
5858
```
5959

60+
## Placement
61+
62+
You can customize the datepicker position using the `placement` prop.
63+
This flexibility ensures that the datepicker fits seamlessly within your user interface.
64+
The placement prop determines where the datepicker will appear in relation to the input field.
65+
66+
<preview>
67+
<p-datepicker placement="left" />
68+
</preview>
69+
70+
```vue
71+
<template>
72+
<p-datepicker placement="left" />
73+
</template>
74+
```
75+
76+
### Combining Placement
77+
78+
You can further refine the placement by combining it with a suffix to adjust vertical/horizontal alignment.
79+
This suffix is useful for aligning the datepicker with the start (`*-start`) or end (`*-end`) of the input field.
80+
81+
<preview class="flex-col space-y-6">
82+
<p-datepicker placement="bottom-end" />
83+
</preview>
84+
85+
```vue
86+
<template>
87+
<p-datepicker placement="bottom-end" />
88+
</template>
89+
```
90+
6091
## Placeholder
6192

6293
You can set input placeholder via `placeholder` props

0 commit comments

Comments
 (0)