Tally UI

TaxBasedOn

Show which address the cart's tax is based on, with a popover that explains how its tax rates were derived.

Import

import { TaxBasedOn } from '@tallyui/components';

Usage

const derivation = taxDerivation(storeSettings, taxLocation);
<TaxBasedOn derivation={derivation} onChangeSetting={openTaxSettings} onViewAllRates={openTaxRates} />

The trigger shows the setting, such as Customer shipping address or Shop base, with a % mark, or a red ! when no tax class matched. The popover walks three steps: the setting the tax is calculated from, the address used (or a missing address), and the rates that match it, grouped by tax class. It is a popover rather than a hover card because a touch screen has no hover, and keyboard shortcuts are blocked while it is open. Rate names show as the store gives them.

Props

PropTypeDefaultDescription
derivationTaxDerivationrequiredFrom taxDerivation in @tallyui/pos: the setting, the address used, any fallback or failure, and the matched classes
onChangeSetting() => void—“Change in Settings › Tax”; the link shows only when given
onViewAllRates() => void—“View all tax rates”; the footer shows only when given, and closes the popover before calling
countryName(code: string) => stringIntl.DisplayNames('en', region)Country code to display name; the default gives the name followed by the code in brackets, or the code alone
classNamestring—Extra classes for the trigger

On this page