Created and maintained by Space Bar Keepers.
npm i spacebar-ui
import { Avatar } from "spacebar-ui"
Background color of Avatar in case of images with transparent background or in case od non-image child.
type: string
default value: "#ccc"
valid values:
- 3-char hex ("#fff")
- 6-char hex ("#ffffff")
- rgb ("rgb(255, 255, 255)")
- rgba ("rgba(255, 255, 255, 1)")
- hsl ("hsl(0, 100%, 100%)")
- hsla ("hsla(100, 100%, 50%, 1)")
object-fit attribute of the inner img-child. Corresponding with CSS object-fit documentation
type: string
default value: "cover"
valid values:
- "contain"
- "cover"
- "fill"
- "none"
- "scale-down"
Inner padding of the Avatar.
type: number
default value: 0\
Size of the Avatar.
type: number
default value: 40\
Variant of the Avatar.
type: string
default value: none
valid values:
- "rounded" (square with rounded corners)
- "circle" (circular shape)
import React from "react";
import { Avatar } from "spacebar-ui";
export default function App() {
return (
<div>
<Avatar
variant="rounded"
backgroundColor="#f00"
size={60}
>
<img
src={"https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Circle-icons-image.svg/1024px-Circle-icons-image.svg.png"}
alt={"user avatar"}
/>
</Avatar>
</div>
);
}
Example available at CodeSandbox.
import { Snackbar } from "spacebar-ui"
State with boolean value. Determines visibility of Snackbar.
type: boolean
Function for changing snackbarOpen state.
type: function
String with Snackbar message.
type: string
Predefined color variations. If specified color and backgroundColor attributes become ineffective.
type: string
valid values:
- "success" (green background, white text)
- "error" (red background, white text)
Background color of Snackbar block. Will not be considered if any snackbarVariant is specified.
type: string
default value: "#fff"
valid values:
- 3-char hex ("#fff")
- 6-char hex ("#ffffff")
- rgb ("rgb(255, 255, 255)")
- rgba ("rgba(255, 255, 255, 1)")
- hsl ("hsl(0, 100%, 100%)")
- hsla ("hsla(100, 100%, 50%, 1)")
Text color inside Snackbar block. Will not be considered if any snackbarVariant is specified.
type: string
default value: "#000"
valid values:
- 3-char hex ("#fff")
- 6-char hex ("#ffffff")
- rgb ("rgb(255, 255, 255)")
- rgba ("rgba(255, 255, 255, 1)")
- hsl ("hsl(0, 100%, 100%)")
- hsla ("hsla(100, 100%, 50%, 1)")
Rewrites time after which Snackbar closes. Defined in milliseconds.
type: number
default value: 2000
import React, { useState } from "react";
import { Snackbar } from "spacebar-ui";
export default function App() {
const [snackbarOpen, setSnackbarOpen] = useState(false);
const handleOpenSnackbar = () => {
setSnackbarOpen(true);
}
return (
<div>
<button onClick={handleOpenSnackbar}>Open Snackbar</button>
<Snackbar
snackbarOpen={snackbarOpen}
setSnackbarOpen={setCustomSnackbarOpen}
snackbarMessage={"This is snackbar message."}
timeout={5000}
backgroundColor={"purple"}
color={"#fff"}
/>
</div>
);
}
Example available at CodeSandbox.
import { ToggleSwitch } from "spacebar-ui"
State of ToggleSwitch.
type: boolean
default value: false\
Function to set state of ToggleSwitch
type: function\
Background color of ToggleSwitch block when checked.
type: string
default value: "#4fbe79"
valid values:
- 3-char hex ("#fff")
- 6-char hex ("#ffffff")
- rgb ("rgb(255, 255, 255)")
- rgba ("rgba(255, 255, 255, 1)")
- hsl ("hsl(0, 100%, 100%)")
- hsla ("hsla(100, 100%, 50%, 1)")
Background color of ToggleSwitch block when unchecked.
type: string
default value: "#bebebe"
valid values:
- 3-char hex ("#fff")
- 6-char hex ("#ffffff")
- rgb ("rgb(255, 255, 255)")
- rgba ("rgba(255, 255, 255, 1)")
- hsl ("hsl(0, 100%, 100%)")
- hsla ("hsla(100, 100%, 50%, 1)")
Background color of the toggle circle.
type: string
default value: "#fff"
valid values:
- 3-char hex ("#fff")
- 6-char hex ("#ffffff")
- rgb ("rgb(255, 255, 255)")
- rgba ("rgba(255, 255, 255, 1)")
- hsl ("hsl(0, 100%, 100%)")
- hsla ("hsla(100, 100%, 50%, 1)")
Url of image/icon to put into toggle circle.
type: string
default value: none\
import React, { useState } from "react";
import {ToggleSwitch} from "spacebar-ui"
export default function App() {
const [checked, setChecked] = useState(false)
return (
<ToggleSwitch
backgroundUnchecked={"#00f"}
backgroundChecked={"#f00"}
checked={checked}
setChecked={setChecked}
switchColor={"#ff0"}
switchImage={"https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Circle-icons-image.svg/1024px-Circle-icons-image.svg.png"}
/>
);
}
Example available at CodeSandbox.
This project was bootstrapped with Create React App.