2.1.9 • Published 1 year ago

@thematic/react v2.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

This is the React package for thematic. It makes things easier to use with React!

Getting started

There is a context provider and hook for retrieving a theme instance in your components.

It looks something like this:

	// in your App.tsx or other 'root'
	import React from 'react'
	import { load } from '@thematic/core'
	import { ThematicProvider } from '@thematic/react'

	const theme = load()

	const App = () => {
		return (
			<ThematicProvider theme={theme}>
				<div>Hello World</div>
			</ThematicProvider>
		)
	}

Later, in some other component:

	import React from 'react'
	import { useThematic } from '@thematic/react'

	const Child = () => {
		const theme = useThematic()

		return (
			<div
				style={{
					backgroundColor: theme.application().background().hex()
					color: theme.application().foreground().hex()
				}}
			>
				Hello again!
			</div>
		)
	}

We also have a handle of styling functions and a root ApplicationStyles component to ease applying basic theme colors to your application defaults.

For example:

	// in your App.tsx or other 'root'
	import React from 'react'
	import { load } from '@thematic/core'
	import { ThematicProvider, ApplicationStyles } from '@thematic/react'

	const theme = load()

	const App = () => {
		return (
			<ThematicProvider theme={theme}>
				<ApplicationStyles />
				<div>Hello World</div>
			</ThematicProvider>
		)
	}

Weaving the ApplicationStyles component in here ensures that your default background, body text, and hyperlink colors match the theme.

2.1.8

1 year ago

2.1.9

1 year ago

2.1.7

1 year ago

2.1.4

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.2

1 year ago

2.1.1

2 years ago

2.1.3

1 year ago

2.0.11

2 years ago

2.0.12

2 years ago

2.1.0

2 years ago

2.0.10

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.5

2 years ago

2.0.6

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.3

2 years ago

1.3.0

2 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

1.0.3

3 years ago

0.9.0

4 years ago

0.8.0

4 years ago