Skip to content

Basic Usage

example.html
<div id="tidbit"></div>
example.ts
import { renderRandomTidbit } from "random-tidbit";
renderRandomTidbit({
target: "#tidbit",
tidbits: [
{ text: 'The Big Bang occurred about 13.8 billion years ago' },
{ text: 'Planet Earth formed about 4.54 billion years ago' },
{ text: 'Homo sapiens appeared on Earth about 300,000 years ago' },
{ text: 'A sock disappeared in the washing machine sometime last Tuesday' }
]
});

The package includes quotes as an example tidbit collection:

import { quotes } from 'random-tidbit/quotes';
import { renderRandomTidbit } from 'random-tidbit';
renderRandomTidbit({
target: '#tidbit',
tidbits: quotes,
});

Each quote has the same generic tidbit shape:

{
text: "I dwell in possibility",
attribution: "Emily Dickinson"
}