Warp Input demo — phone numbers, addresses, money, IDs, signatures and form helpers for Filament. Change or delete anything; the data is reset every hour. warpui.com About Warp Input Docs Ask a question Support
Skip to content

Numbers, discounts & ratings

NumberInput replaces TextInput::make()->numeric() for quantities and saves a number (12, 1.5). DiscountInput takes a percentage or an amount. RatingInput is a star rating that can also be hearts, numbers or faces.

The − and + buttons

The buttons add or take away one step (->step(), 1 by default) and stop at ->minValue() and ->maxValue(). Hold a button to keep counting; it speeds up the longer you hold.

Note: Try it

Press + three times: 3. Hold + down: it counts faster and faster and stops at 100. At 0, − is greyed out and can’t be pressed.

The arrow keys, and Shift for bigger steps

In the field, ↑ and ↓ change the value by one step. With Shift held down, they change it by ten steps. This field has ->step(0.25): one step is a quarter of an hour.

Note: Try it

Click the field and press ↑ twice: 0.5 (30 minutes). Hold Shift and press ↑ once: 3 (ten steps of 15 minutes, 2 hours 30 minutes more). It never goes above 24 or below 0.

h

Without the buttons

->buttons(false) hides − and +, for fields where people always type the number. ↑ and ↓ still work.

Note: Try it

There are no buttons next to the field. Click it and press ↑: 1.

Grouping and short forms

Like the money field, digits are grouped as you type, and full-width digits and short forms of the screen’s language are read (1.5k in English, 3万 on a Japanese screen).

Note: Try it

Type 12000: it shows 12,000. Type 1.5k and click outside the field: 1,500. “Show what would be saved” shows the number 1500.

One unit next to the number

->unit('boxes') writes the unit on the right of the field. Only the number is saved.

Note: Try it

Type 40 and press “Show what would be saved”: 40, without “boxes”.

boxes

A choice of units

->unit(['lb' => 'lb', 'kg' => 'kg']) puts a small select on the right. The chosen unit is saved to weight_unit (->unitField() changes the name).

Note: Try it

Type 25, choose kg on the right and press “Show what would be saved”: weight 25 and weight_unit "kg".

Decimal places

->decimals(2) rounds to two places and always shows them. Without it, the number is kept as typed. This field also has ->step(0.5).

Note: Try it

Type 3 and click outside the field: 3.00. Press +: 3.50. Type 2.456: 2.46.

ft

Whole packs only (rounded up)

->packSize(12) keeps the quantity in whole packs of 12. A number that doesn’t fill whole packs is raised to the next pack, with a note under the field. The server rounds it again before saving.

Note: Try it

Type 30 and click outside the field: it becomes 36, and the note says “Sold in packs of 12, so this was changed to 36.”

pcs

Whole packs, warning only

->packSize(10, PackSizeRounding::Warn) keeps the number that was typed and only shows a note. For goods that are usually, but not always, sold by the pack.

Note: Try it

Type 25 and click outside the field: 25 stays, and the note says it doesn’t fill whole packs. Type 30: no note.

A discount as a percentage or an amount

DiscountInput takes either. ->of('subtotal') is the amount the percentage applies to. Under the field, the other side is shown. The field saves the amount of the discount.

Note: Try it

Type 10%: under the field, “= $41.10”. Change the subtotal to 500: “= $50.00”. Then press $ on the right of the discount: the field shows 50.00, and under it “= 10% of $500.00”.

$

Saving the percentage too

->percentField('order_discount_percent') also saves the percentage to another column, so you can show “10% off” later. ->amountField() does the same for the amount.

Note: Try it

Type 10% and press “Show what would be saved”: the discount 41.10 and the percentage 10.

$

Saving a percentage instead of an amount

->storeAs(DiscountType::Percent) saves the percentage in the field’s own column: right for a customer’s usual discount, which has no amount yet. Without ->of(), an amount can’t be turned into a percentage.

Note: Try it

Type 15% and press “Show what would be saved”: 15.

Starting with an amount

An empty discount field starts with %. ->defaultType(DiscountType::Amount) starts it with $, for credits and coupons of a fixed amount.

Note: Try it

$ on the right is already selected. Type 25: under the field, “= 10% of $250.00”.

$

Fees above 100%

Percentages stop at 100% by default. ->maxPercent(null) removes the limit, for markups and fees. Negative values are still refused.

Note: Try it

Type 150%: under the field, “= $120.00”. Press “Show what would be saved”: no error.

$

Stars

RatingInput is five stars by default. Click a star to choose it; click the same star again to clear the rating. The number is saved (4), or null.

Note: Try it

Click the fourth star and press “Show what would be saved”: 4. Click the fourth star again: the rating is cleared (null).

Press the selected rating again, or press Delete, to clear it.

Half stars

->allowHalf() lets the left half of a star choose x.5.

Note: Try it

Click the left half of the fourth star: 3.5. Click its right half: 4.

Press the selected rating again, or press Delete, to clear it.

Hearts

->style(RatingStyle::Hearts) draws hearts instead of stars. They work the same way.

Note: Try it

Click the third heart: 3.

Press the selected rating again, or press Delete, to clear it.

A scale of 1 to 10

->style(RatingStyle::Numbers)->max(10) shows the numbers 1 to 10, as in “How likely are you to recommend us?”. ->max() takes 1 to 10.

Note: Try it

Click 8 and press “Show what would be saved”: 8.

Press the selected rating again, or press Delete, to clear it.

Faces

->style(RatingStyle::Faces) shows five faces, from very unhappy to very happy. A face is saved as 1 to 5.

Note: Try it

Click the fourth face (🙂) and press “Show what would be saved”: 4. Screen readers hear “Happy (4 out of 5)”.

Press the selected rating again, or press Delete, to clear it.

Rating with the keyboard

The rating can be reached with Tab like any field. ← → (or ↑ ↓) move by one step (half a step here, with ->allowHalf()), Home and End go to the lowest and highest, 1 to 9 jump to that value, and Delete, Backspace or 0 clear it. Screen readers hear “3.5 out of 5”.

Note: Try it

Click the third star (3), then press → (3.5), End (5), 1 (1), Home (0.5, the lowest with halves) and Delete (cleared).

Press the selected rating again, or press Delete, to clear it.

A rating that can’t be cleared

->clearable(false) keeps the value when the chosen star is clicked again, so a rating can only be changed, not removed.

Note: Try it

Click the third star, then click it again: it stays 3.

Another colour

->color('#0d9488') fills the stars with any CSS colour. By default stars are amber, hearts red and numbers the panel’s colour.

Note: Try it

Click the fourth star: the stars are teal, like this panel.

Press the selected rating again, or press Delete, to clear it.

Saved ratings in tables and details

RatingColumn and RatingEntry draw a saved rating: stars (half stars too), “8 out of 10” for numbers, or a face. Use ->maxRating(10) and ->style(). Under a table, RatingAverage shows the average.

Note: Try it

Compare the three ratings below with what is saved (in brackets).

4.5 out of 5
8 out of 10
4 out of 5