Mention people with @ and records with #
MentionTextarea suggests people after @ and records after # while you type. The field shows “@Jordan Reyes”; what is saved is the text with each key, “@[Jordan Reyes](1)”, in your own text column, so older notes stay readable.
Note: Try it
Type Please ask @jor and press Enter on Jordan Reyes. Then type about #bay and choose Bayside Grocers. Press “Show what would be saved”: each name is followed by its id in ( ), the person’s and the customer’s.
Characters left
->maxLength(40)->counter() shows how many characters are left under the field. An emoji like 👨👩👧 counts as one character, the way people see it (Filament’s own count says 5).
Note: Try it
Type Spring sale and the counter says “29 characters left”. Add 👨👩👧 at the end: it goes down by just 1.
Counting without a limit
->counter() without maxLength() shows how many characters have been typed.
Note: Try it
Type Heavy-duty storage shelf and the counter says “24 characters”.
Too long: shown in red and not saved
Pasted text is never cut off. The counter turns red and says how much is over, and the server checks the same count, so the text can’t be saved until it is shorter.
Note: Try it
Paste Free shipping on all orders this week (37 characters): the counter says “17 characters too many” in red. Press “Show what would be saved” to see the error.
Full-width characters count as 2
->countFullwidthAsTwo() counts kanji, kana and full-width letters as 2 and plain letters as 1, the way older Japanese systems count. maxLength(20) then means 20 half-width places.
Note: Try it
Type ABC and the counter says “17 characters left”. Then type 港区倉庫 (4 kanji): it goes down by 8, to “9 characters left”.
Counting bytes (UTF-8)
->countBytes('UTF-8') counts bytes instead of characters, for database columns or exports that are limited in bytes. maxLength(30) means 30 bytes.
Note: Try it
Type Cafe and the counter says “26 bytes left”. Type Café instead: é takes 2 bytes, so it says “25 bytes left”.
Counting bytes (Shift_JIS)
->countBytes('Shift_JIS') counts the way older Japanese systems and shipping label printers do: plain letters and half-width kana are 1 byte, everything else is 2.
Note: Try it
Type 東京倉庫 and the counter says “22 bytes left” (4 kanji × 2). Add ソウコ in half-width kana: only 3 more bytes.
Text messages (SMS)
->countSms(maxMessages: 2) shows how many text messages the text takes and how many characters are left in the current one. One message holds 160 characters, but only 70 once there is an emoji. More than 2 messages can’t be saved.
Note: Try it
Type Your order has shipped. The counter says “1 text message · 137 characters left in this one”. Add 📦 at the end: it drops to 45 left, because a message with an emoji holds only 70 (the emoji itself takes 2).
Half-width letters and digits, in upper case
->normalize(TextNormalization::Halfwidth, TextNormalization::Uppercase) turns full-width letters and digits into normal ones and makes everything upper case while you type. The server does the same before saving.
Note: Try it
Type hb-1042: it becomes HB-1042. Full-width hb-1042 becomes HB-1042 too.
Full-width letters and digits
->normalize(TextNormalization::Fullwidth) does the opposite: normal letters, digits and symbols become full-width, for older systems that only take full-width text.
Note: Try it
Type AB-12: it becomes AB-12.
Half-width kana to full-width kana
->normalize(TextNormalization::FullwidthKana) turns half-width kana (カタカナ), which bank and old systems often send, into normal full-width kana.
Note: Try it
Type or paste ハーバー サプライ in half-width kana: it becomes ハーバー サプライ.
Always katakana
->normalize(TextNormalization::Katakana) turns hiragana and half-width kana into katakana — the usual form for the reading of a Japanese name.
Note: Try it
Type やまだ たろう: it becomes ヤマダ タロウ.
Always hiragana
->normalize(TextNormalization::Hiragana) turns katakana and half-width kana into hiragana.
Note: Try it
Type ヤマダ タロウ: it becomes やまだ たろう.
Always lower case
->normalize(TextNormalization::Lowercase) makes every letter lower case, for tags, user names and codes that must match exactly. (Uppercase is used in the product code above.)
Note: Try it
Type Spring-SALE: it becomes spring-sale.
Extra spaces removed
->normalize(TextNormalization::Squish) turns double spaces (also full-width ones) into one, and removes spaces at the start and end when you leave the field.
Note: Try it
Type New York with three spaces between the words: only one is left. A space typed at the end stays until you click outside the field.
Extra spaces removed, line breaks kept
In WarpTextarea, TextNormalization::Squish tidies each line and removes empty lines at the start and end, but keeps the line breaks in between.
Note: Try it
Type Leave at the back door, press Enter, and type Ring twice. Press “Show what would be saved”: one space between the words, and the two lines are kept.
Furigana (the reading of a Japanese name)
->furigana('contact_name_kana') writes the reading into another field while a name is typed with the Japanese keyboard. Once you type in the reading field yourself, it is no longer overwritten. Pasted names have no reading, so it stays empty.
Note: Try it
Turn on the Japanese keyboard and type yamada taro, converting it to 山田 太郎: the right field fills in ヤマダ タロウ as you type.
Furigana in hiragana
->furigana('company_kana', hiragana: true) writes the reading in hiragana instead of katakana.
Note: Try it
With the Japanese keyboard, type toukyou souko and convert it to 東京 倉庫: the right field fills in とうきょう そうこ.
Katakana only (validation)
->rule(new Kana) refuses anything but katakana, the long dash ー, the dot ・ and spaces. new Kana(hiragana: true) asks for hiragana instead.
Note: Try it
Type 山田 and press “Show what would be saved”: “Use katakana only.” Then type ヤマダ instead: it is saved.
Saved replies in a one-line field
->templates([...]) adds a button at the right end of the field. It opens a list you can search, and the chosen text goes in where the cursor is.
Note: Try it
Click the speech bubble at the right end of the field and choose “Order shipped”: Your order has shipped is put in the field.
Saved replies in a text area
In WarpTextarea the button sits under the field. The texts can have several lines and can be put one after another to build a reply.
Note: Try it
Click “Insert a saved reply” under the field, type delay in the search box and choose “Delivery delay”. Then add “Sign-off” at the end.
Warning about words
->warnWords(['refund', 'discount']) shows a note under the field when one of the words is used. It is only a reminder: the text can still be saved.
Note: Try it
Type We can offer a Discount: “Contains “discount”. Check this before you send it.” appears. Upper and lower case don’t matter.
Words that can’t be saved
->rejectWords(['confidential', 'internal only']) shows the word in red, and the RejectWords rule refuses the text on the server.
Note: Try it
Type This price is internal only: a red note appears. Press “Show what would be saved” to see the error.
Warning about personal data
->warnPersonalData() warns about what looks like a card number, a Japanese My Number, a phone number or an email address. Card numbers are hidden in the warning. It is checked in the browser only and never stops saving.
Note: Try it
Type Card 4111 1111 1111 1111: “This looks like a card number (•••• 1111).” appears. Try dana@harborsupply.com or 617-555-0123 too.
Long text in tables and details
There is no special column: Filament’s TextColumn and TextEntry already do it. Show the reading under a name with ->description() (->belowContent() in details), and shorten long text with ->limit(50) and a ->tooltip() that uses MergeTags::render().
Note: Try it
Point at the shortened reply: the whole text appears, with the customer’s name and the order number filled in.