Methods for applying color-related styles to React components.
import { View } from "tile-css"
const KittenButton = View('button')
.fg("#ff0")
.bg({
url: 'https://placekitten.com/100x100.jpg',
size: 'cover'
})
.element();
export const FancyButton = ({ children }) => (
<KittenButton>{children}</KittenButton>
);Apply multiple color-related styles at once.
View()
.color({
fg: 'white',
bg: 'blue',
border: 'red',
caret: 'green',
placeholder: 'lightgray',
selectionBg: 'yellow',
selectionFg: 'black',
outline: 'orange'
})
.element();fg: Foreground colorbg: Background color or BGOptionsborder: Border colorcaret: Caret colorplaceholder: Placeholder text colorselectionBg: Selection background colorselectionFg: Selection text coloroutline: Outline color
Set the foreground (text) color.
View()
.fg('blue')
.element();Set background styling.
To set solid color:
View()
.bg('blue')
.element();To set a background image:
View()
.bg({ url: 'https://foo.com/bar.png' }) // use `src` property for non-url values
.element()More complex example:
View()
.bg({
color: 'blue',
url: 'image.jpg',
size: 'cover',
position: 'center',
repeat: 'no-repeat'
})
.element();color: Background colorurl: Background image URL, shortcut forurl(...)src: Background image sourcebase64: Base64 encoded background imagesize: 'cover' | 'contain' | 'auto'position: string | [string, string]repeat: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'
Set the placeholder text color.
View('input')
.placeholder('lightgray')
.element();Alias for bg. Uses the same options.
View()
.fill('red')
.element();