forked from styled-components/styled-components-website
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
styled-components#503 added useTheme hook documentation (styled-compo…
…nents#569) * feat: add useTheme hook in helper api section * chore: add tag to the header * chore: change useContext mention to useTheme on Theming section * chore: add useContext metion again Co-authored-by: Ayoub Aabass <ayoub@aabass.net> Co-authored-by: Evan Jacobs <570070+probablyup@users.noreply.github.com>
- Loading branch information
1 parent
4ca8572
commit 665aa17
Showing
3 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### `useTheme` | v5 | ||
|
||
This is a custom hook to get the current theme from a `ThemeProvider`. | ||
|
||
```jsx | ||
import { useTheme } from 'styled-components' | ||
|
||
function MyComponent() { | ||
const theme = useTheme() | ||
console.log('Current theme: ', theme) | ||
|
||
// ... | ||
} | ||
``` | ||
|
||
> All styled components [automatically receive the theme as a prop](/docs/advanced#theming), so this is only necessary if you wish to access the theme for other reasons. |