- Welcome
- Getting started
- Latest updates
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- App Search Modal
- Aria live
- Autosuggest
- Badge
- Banner alert
- Bar chart
- Blockquote
- Bottom navigation
- Bottom sheet
- Breadcrumb
- Breakpoint
- Button
- Calendar
- Card
- Card list
- Card button
- Carousel
- Checkbox
- Chip
- Chip group
- Code
- Content cards
- Data Table
- Datepicker
- Description list
- Dialog
- Divider
- Drawer
- Field Set
- Flare
- Flat list
- Flight leg
- Floating action button
- Floating notification
- Form label
- Form validation
- Graphic promotion
- Horizontal navigation
- Icon
- Image
- Image Gallery
- Infinite scroll
- Info Banner
- Inset Banner
- Link
- List
- Map
- Mobile scroll container
- Modal
- Navigation bar
- Navigation Tab Group
- Nudger
- Overlay
- Page indicator
- Pagination
- Panel
- Phone input
- Picker
- Popover
- Price
- Progress bar
- Radio button
- Rating
- Rating Bar
- Scrollable calendar
- Search Modal
- Section header
- Section list
- Select
- Skeleton
- Skip link
- Slider
- Snackbar
- Snippet
- Spinner
- Split input
- Star rating
- Swap Button
- Switch
- Table
- Text
- Text input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable native feedback
- Touchable overlay
- Search Input Summary
- Content
- Accessibility
- Contributing
- Localisation
Nudger
Nudgers allow users to quickly specify a value within a given range.
Default
Nudgers come with decrease and increase buttons on either side of the selected value. A minimum and maximum value need to be provided.
On Dark
On Dark version allows for the nudger to be used on dark backgrounds.
Configurable
A configurable nudger to support non-numeric variants, for example dates and strings.
bpk-component-nudger
Backpack nudger component.
Installation
Check the main Readme for a complete installation guide.
Usage
BpkNudger
import { Component } from 'react';
import BpkLabel from '@skyscanner/backpack-web/bpk-component-label';
import BpkNudger from '@skyscanner/backpack-web/bpk-component-nudger';
class App extends Component {
constructor() {
super();
this.state = {
value: 1,
};
}
handleChange = value => {
this.setState({ value });
};
render() {
return (
<div>
<BpkLabel htmlFor="my-nudger">Number of passengers</BpkLabel>
<BpkNudger
id="my-nudger"
min={1}
max={10}
value={this.state.value}
onChange={this.handleChange}
decreaseButtonLabel="Decrease"
increaseButtonLabel="Increase"
/>
</div>
);
}
}
BpkConfigurableNudger
import { Component } from 'react';
import BpkLabel from '@skyscanner/backpack-web/bpk-component-label';
import { BpkConfigurableNudger } from '@skyscanner/backpack-web/bpk-component-nudger';
const options = ['economy', 'premium', 'business', 'first'];
const compareValues = (value1, value2) => {
const [aIndex, bIndex] = [options.indexOf(value1), options.indexOf(value2)];
return aIndex - bIndex;
};
const incrementValue = currentValue => {
const [aIndex] = [options.indexOf(currentValue) + 1];
return options[aIndex];
};
const decrementValue = currentValue => {
const [aIndex] = [options.indexOf(currentValue) - 1];
return options[aIndex];
};
const formatValue = currentValue => currentValue.toString();
class App extends Component {
constructor() {
super();
this.state = {
value: 1,
};
}
handleChange = value => {
this.setState({ value });
};
render() {
return (
<div>
<BpkLabel htmlFor="nudger">Number of passengers</BpkLabel>
<BpkConfigurableNudger
id="nudger"
min="economy"
max="first"
value={this.state.value}
onChange={this.handleChange}
decreaseButtonLabel="Decrease"
increaseButtonLabel="Increase"
compareValues={compareValues}
incrementValue={incrementValue}
decrementValue={decrementValue}
formatValue={formatValue}
/>
</div>
);
}
}
Props
Check out the full list of props on Skyscanner's design system documentation website.
Props
Made with ❤️ by Skyscanner © 2024
© 2024 Skyscanner Backpack. Page last updated on Oct 2, 2023, 15:59