Indent text in a cell



Is there anyway to indent the contents of a cell for visual purposes? The goal would be tasks, sub tasks and additional sub tasks.




Depends: What kind of cell? :wink:

Or, rather, what kind of cell, and what kind of view?

Actually, it’s even more complicated than that…

In grid view with row-height set to ‘short’ — that is, the default, single-line height — cells are styled 'white-space: nowrap'. To cite the applicable section of the HTML spec:

[L]eading white space characters, such as spaces, horizontal tabs, form feeds and line breaks […] must be ignored, and any subsequent sequence of contiguous white space characters must be replaced by a single […] space.

In other words (as you’ve undoubtedly discovered), attempting to indent text values in a cell by inserting leading spaces will fail, as the browser obediently ignores them. This applies to single-line and long text fields and to formula fields that return a text value.

However, for grid views with row-height set to anything other than ‘short,’ cells are styled as 'white-space: pre-wrap', which preserves white-space characters. Try this: In a single-line text field displayed using a standard grid view, enter ' test' — that’s four spaces followed by ‘test’. (You’ll have to enter edit mode by hitting the return key first; otherwise, your initial space character will open the expanded record window.) When you exit the cell, the leading spaces disappear. Now click the row-height control (third icon from the right, between ‘color’ and ‘share view’) and set row-height to anything other than ‘short’. The leading spaces return, and ‘test’ appears indented.¹ So that’s one solution: Change row-height.

Fortunately, there’s another way to force indentation without losing half the displayed records per page: Use an alternate spacing character. There are a bunch of them, in various widths, defined in the Unicode spec, from U+2000 through U+200A. Most² appear to be supported by most of the fonts Airtable specifies as defaults for its UI, and with enough time, patience, and caffeine, one can create elaborate indentation schemes that align row-to-row

If life’s too short for such things, though, just use U+00A0, the no-break space: It’s universally supported, and it won’t be swallowed, even on short-rowed grid views.⁴

Note: None of the preceding comment applies to Airtable’s mobile versions, which I have not tested.

  1. This is also the easiest way to make certain you don’t have multiple white-space characters embedded within a text field. Recently, while working on a query engine for a client base, I ran into what seemed an insurmountable problem in that a search term I entered blithely refused to match an identical field value I could see right in front of me. After rewriting my formula a half-dozen times and testing it successfully on single-word searches, I was ready to claim defeat on the entire project when, for some reason, I decided to change line-height. When I did, I discovered every occurrence of the target phrase found within the client-provided base contained, for some reason, a newline character ('\n') instead of a space between the first and second words. With row-height set to ‘short,’ 'word1 word2', 'word1 word2' and 'word1\nword2' all look the same, but none will match either of the others in a FIND() or SEARCH() statement.
  2. In particular, U+2009, thin space, is not found in the Segoe UI font loaded by most modern Windows systems.
  3. However, when I attempted to demonstrate this hack at Airtable HQ earlier this year, it failed, as — at the time, at least — Mac Safari did not correctly support fractional space characters.
  4. The easiest way to insert a no-break space is to copy-and-paste it from elsewhere. I typically get it from the Windows Character Map (it’s the empty box between '~' (tilde) and '¡' (inverted exclamation mark). Presumably, the OS X Character Viewer provides similar functionality. To use the no-break space in a formula, enclose it in single quotes as one would any character: REPT(' ',5).