Skip to content

Commit a1b1640

Browse files
committed
📝 Update documentation
1 parent c77fe58 commit a1b1640

File tree

3 files changed

+105
-34
lines changed

3 files changed

+105
-34
lines changed

website/src/pages/docs/cursor.mdx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# `<Cursor />` API
1+
# <a name="cursor-api"></a>`<Cursor />` API
22

33
This component will render the cursor.
44

5-
## Props
5+
## <a name="props"></a>Props
66

77
<table>
88
<thead>
@@ -15,35 +15,41 @@ This component will render the cursor.
1515
</thead>
1616
<tbody>
1717
<tr>
18-
<td>zIndex</td>
18+
<td>[zIndex](#zindex-prop)</td>
1919
<td>number</td>
2020
<td>9999</td>
2121
<td>Z-index of the cursor</td>
2222
</tr>
2323
<tr>
24-
<td>theme</td>
24+
<td>[theme](#theme-prop)</td>
2525
<td>CursorTheme</td>
2626
<td>\{}</td>
2727
<td>Theme configuration for variants and rules</td>
2828
</tr>
2929
<tr>
30-
<td>defaultColor</td>
30+
<td>[scaleOnClick](#scale-on-click-prop)</td>
31+
<td>boolean</td>
32+
<td>true</td>
33+
<td>Scale cursor on click</td>
34+
</tr>
35+
<tr>
36+
<td>[defaultColor](#default-color-prop)</td>
3137
<td>string</td>
3238
<td>auto</td>
3339
<td>Default HSL color value</td>
3440
</tr>
3541
</tbody>
3642
</table>
3743

38-
### `zIndex` Prop
44+
### <a name="zindex-prop"></a>`zIndex` Prop
3945

4046
You can change the z-index of the cursor by modifying the `zIndex` prop. Defaults to `9999`.
4147

4248
```jsx
4349
<Cursor zIndex={1000} />
4450
```
4551

46-
### `theme` Prop
52+
### <a name="theme-prop"></a>`theme` Prop
4753

4854
The theme prop allows you to customize the cursor's appearance and behavior through variants and rules.
4955

@@ -80,27 +86,21 @@ const theme: CursorTheme = {
8086

8187
> It is also possible to add several selectors in this way `selector: ['.custom-element1', '.custom-element2']`
8288
83-
### `defaultColor` Prop
89+
### <a name="scale-on-click-prop"></a>`scaleOnClick` Prop
8490

85-
Override the default cursor color. The value should be in HSL format.
91+
If `false`, do not scale cursor when clicking. Defaults to `true`.
8692

8793
```jsx
88-
<Cursor defaultColor="349, 80%, 59%" />
94+
<Cursor scaleOnClick={false} />
8995
```
9096

91-
## Default Behavior
92-
93-
The cursor automatically detects and responds to:
97+
### <a name="default-color-prop"></a>`defaultColor` Prop
9498

95-
- Interactive elements (buttons, links, inputs)
96-
- Text elements
97-
- Disabled elements
98-
- Elements with `role="button"` or `role="link"`
99-
- Elements with click handlers
99+
Change the default cursor color. The value should be in **HSL format**. By default, the cursor uses the HSL values from the <a href="https://ui.shadcn.com/colors" target="_blank" rel="noopener noreferrer">Tailwind CSS color palette</a>:
100100

101-
It will adjust its appearance based on the element being hovered:
101+
- Dark mode: `0 0% 98%` (zinc-50)
102+
- Light mode: `240 10% 3.9%` (zinc-950)
102103

103-
- Regular elements: small dot
104-
- Interactive elements: larger dot
105-
- Text: vertical bar that matches text height
106-
- Disabled elements: semi-transparent dot
104+
```jsx
105+
<Cursor defaultColor="349, 80%, 59%" />
106+
```

website/src/pages/docs/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Getting Started
1+
# <a name="getting-started"></a>Getting Started
22

33
Add a custom animated cursor to your React app with <a href="https://github.com/GuiEpi/react-dot-cursor" target="_blank" rel="noopener noreferrer">react-dot-cursor</a>
44

5-
### Install with pnpm
5+
### <a name="install-pnpm"></a>Install with pnpm
66

77
```sh
88
pnpm add react-dot-cursor
99
```
1010

11-
### Install with NPM
11+
### <a name="install-npm"></a>Install with NPM
1212

1313
```sh
1414
npm install react-dot-cursor
1515
```
1616

17-
## Basic usage
17+
## <a name="basic-usage"></a>Basic usage
1818

1919
Add the `Cursor` component to your app.
2020

website/src/pages/docs/styling.mdx

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Styling
1+
# <a name="styling"></a>Styling
22

3-
## Color Configuration
3+
## <a name="color-configuration"></a>Color Configuration
44

5-
### Using CSS Variables
5+
### <a name="using-css-variables"></a>Using CSS Variables
66

77
You can style the cursor by setting the `--cursor-color` CSS variable. The value should be in **HSL format**.
88

@@ -12,7 +12,7 @@ You can style the cursor by setting the `--cursor-color` CSS variable. The value
1212
}
1313
```
1414

15-
### Dark Mode Support
15+
### <a name="dark-mode-support"></a>Dark Mode Support
1616

1717
The cursor automatically detects system dark mode preferences and adjusts its color. You can override this behavior:
1818

@@ -30,7 +30,64 @@ The cursor automatically detects system dark mode preferences and adjusts its co
3030
}
3131
```
3232

33-
## Variants Styling
33+
## <a name="default-variants"></a>Default Variants
34+
35+
The cursor comes with predefined variants for common interactions. You can override these in your [theme configuration](#variants-styling):
36+
37+
```tsx
38+
const defaultVariants: Record<CursorType, CursorVariant> = {
39+
default: {
40+
style: {
41+
scale: 1,
42+
borderRadius: '50%',
43+
width: 16,
44+
height: 16,
45+
},
46+
},
47+
hover: {
48+
style: {
49+
scale: 1,
50+
borderRadius: '50%',
51+
width: 30,
52+
height: 30,
53+
},
54+
},
55+
text: {
56+
style: {
57+
scale: 1,
58+
width: 3,
59+
height: fontSize,
60+
borderRadius: '1rem',
61+
},
62+
},
63+
disabled: {
64+
style: {
65+
scale: 1,
66+
borderRadius: '50%',
67+
opacity: 0.5,
68+
width: 12,
69+
height: 12,
70+
},
71+
},
72+
};
73+
```
74+
75+
It automatically detects and responds to:
76+
77+
- Interactive elements (buttons, links, inputs)
78+
- Text elements
79+
- Disabled elements
80+
- Elements with `role="button"` or `role="link"`
81+
- Elements with click handlers
82+
83+
It will adjust its appearance based on the element being hovered:
84+
85+
- Regular elements: small dot
86+
- Interactive elements: larger dot
87+
- Text: vertical bar that matches text height
88+
- Disabled elements: semi-transparent dot
89+
90+
## <a name="variants-styling"></a>Variants Styling
3491

3592
Each variant can have its own unique styling through the theme configuration:
3693

@@ -59,10 +116,17 @@ const theme: CursorTheme = {
59116
},
60117
},
61118
},
119+
rules: [
120+
{
121+
selector: '.custom-element',
122+
variant: 'custom',
123+
priority: 1,
124+
},
125+
],
62126
};
63127
```
64128

65-
## Animation Customization
129+
## <a name="animation-customization"></a>Animation Customization
66130

67131
The cursor uses Motion for animations. You can customize the animation properties in your variants:
68132

@@ -81,10 +145,17 @@ const theme: CursorTheme = {
81145
},
82146
},
83147
},
148+
rules: [
149+
{
150+
selector: '.custom-element',
151+
variant: 'custom',
152+
priority: 1,
153+
},
154+
],
84155
};
85156
```
86157

87-
## CSS Classes
158+
## <a name="css-classes"></a>CSS Classes
88159

89160
The cursor component provides the following CSS classes for additional styling:
90161

0 commit comments

Comments
 (0)