Skip to content

Commit

Permalink
Merge pull request #131 from Calinou/add-border-radius-variable
Browse files Browse the repository at this point in the history
Add a CSS variable to customize the tooltip's border radius
  • Loading branch information
kazzkiq authored Apr 16, 2020
2 parents 8f2f899 + 2dd056a commit 4373ec0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion balloon.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
:root {
--balloon-border-radius: 2px;
--balloon-color: rgba(16, 16, 16, 0.95);
--balloon-font-size: 12px;
--balloon-move: 4px; }
Expand All @@ -20,7 +21,7 @@ button[aria-label][data-balloon-pos] {
text-shadow: none;
font-size: var(--balloon-font-size);
background: var(--balloon-color);
border-radius: 2px;
border-radius: var(--balloon-border-radius);
color: #fff;
content: attr(aria-label);
padding: .5em 1em;
Expand Down
2 changes: 1 addition & 1 deletion balloon.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ If for some reason you do not want animations in your tooltips, you can use the

### Customizing Tooltips

Balloon.css exposes three CSS variables to make it easier to customize tooltips: `--balloon-color`, `--balloon-font-size` and `--balloon-move`. This way you can use custom CSS to make your own tooltip styles:
Balloon.css exposes CSS variables to make it easier to customize tooltips:

- `--balloon-border-radius`
- `--balloon-color`
- `--balloon-font-size`
- `--balloon-move`

This way, you can use custom CSS to make your own tooltip styles:

```css
/* Add this to your CSS */
Expand All @@ -116,8 +123,9 @@ Balloon.css exposes three CSS variables to make it easier to customize tooltips:
If you want to customize tooltips globally, use the `:root` selector:

```css
/* All tooltips would now be blue */
/* All tooltips would now be square and blue */
:root {
--balloon-border-radius: 0;
--balloon-color: blue;
}
```
Expand Down
5 changes: 3 additions & 2 deletions src/balloon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// -----------------------------------------

:root {
--balloon-border-radius: 2px;
--balloon-color: #{$balloon-bg};
--balloon-font-size: #{$balloon-base-size};
--balloon-move: #{$balloon-move};
Expand All @@ -41,7 +42,7 @@ button[aria-label] {
@include normalized-text();

background: var(--balloon-color);
border-radius: 2px;
border-radius: var(--balloon-border-radius);
color: #fff;
content: attr(aria-label);
padding: .5em 1em;
Expand All @@ -62,7 +63,7 @@ button[aria-label] {
&:hover, &[data-balloon-visible], &:not([data-balloon-nofocus]):focus {
&:before,
&:after {
opacity: 1;
opacity: 1;
pointer-events: none;
}
}
Expand Down

0 comments on commit 4373ec0

Please sign in to comment.