@@ -48,7 +48,8 @@ Checkout out my <u use:tooltip={{ content: 'Hello World!' }}>tooltip</u>
4848| content | The string or object containing componentref and props | ` string ` | ` object ` component (default: ``) |
4949| maxWidth | The max allowable width of the tooltip content | ` number ` (default: ` 200 ` ) |
5050| position | The position where the tooltip should appear relative to its parent | ` string ` (default: ` top ` ) |
51- | theme | The CSS theme class name | ` string ` (default: ``) |
51+ | theme | The CSS theme class name | ` string ` (default: ``) |
52+ | styles | The object containing theme variable overrides | ` object ` (default: ` null ` ) |
5253
5354#### Using components as content
5455| Prop | Description | Value |
@@ -65,6 +66,57 @@ Checkout out my <u use:tooltip={{ content: 'Hello World!' }}>tooltip</u>
6566Checkout out my <span use:tooltip={{ content: { component: ComponentAsTooltip, props: { title: 'Hello World!' } } }}>tooltip</span>
6667```
6768
69+ ## Theming
70+ You can customize tooltips theme using several methods:
71+ - Assign a theme class name via the ` theme ` property that includes all of your CSS variables overrides
72+ - Define the overrides directly using the ` styles ` property
73+ - Override the CSS variables globally
74+
75+ Tooltip CSS variables:
76+
77+ ``` css
78+ --tooltip-background-color: rgba(0, 0, 0, 0.9 );
79+ --tooltip-border-radius: 4px;
80+ --tooltip-box-shadow: 0 1px 20px rgba(0, 0, 0, 0.25 );
81+ --tooltip-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell,
82+ 'Helvetica Neue', sans-serif ;
83+ --tooltip-font-size: 14px;
84+ --tooltip-font-weight: 500;
85+ --tooltip-line-height: 1.25rem;
86+ --tooltip-color: #fff;
87+ --tooltip-offset-x: 12px;
88+ --tooltip-offset-y: 12px;
89+ --tooltip-padding: 12px;
90+ --tooltip-z-index: 100;
91+ --tooltip-arrow-size: 10px;
92+ ```
93+
94+ ### Using the theme property
95+
96+ ```svelte
97+ // action
98+ <span title="hello world!" use :tooltip={{ theme : ' custom-tooltip' }}> Hover over me</span >
99+
100+ // component
101+ <Tooltip content="hello world!" theme="custom-tooltip "> Hover over me</Tooltip>
102+
103+ <style >
104+ :global(.tooltip.custom-tooltip ) {
105+ --tooltip-background-color : hotpink ;
106+ --tooltip-box-shadow : 0 1px 8px pink ;
107+ }
108+ </style >
109+ ```
110+
111+ ### Using the style property
112+ ```svelte
113+ // action
114+ <span title="hello world!" use :tooltip={{ style : { backgroundColor: ' blue' , borderRadius: ' 10px' } }}> Hover over me</span >
115+
116+ // component
117+ <Tooltip content="hello world!" style={{ style : { backgroundColor: ' blue' } }}> Hover over me</Tooltip>
118+ ```
119+
68120## Changelog
69121
70122[Changelog ](CHANGELOG.md )
0 commit comments