I'm using a lightning:datatable to retreive data and want the date-formatted columns to be right-aligned. I've figured out how to right-align the actual data, but the column heading is still left-aligned and I can't find any documentation on how to right-align the heading to match the data alignment.

datatable definition:

            data="{! v.eeObject.serviceBranches }"
            columns="{! v.serviceColumns }"

column definition extract:

component.set('v.serviceColumns', [
{label: 'Entry Date', fieldName: 'serviceEntryDate', type: 'date-local', 
typeAttributes:{ month: "numeric", day: "numeric" }, cellAttributes: { alignment: 'right' }}


As you'll see in the screenshot, the dates right-align as expected but the column heading is still left-aligned. I haven't found anything in the documentation that explains how to right-align the heading to match.

Left-aligned heading, right-aligned data


I had the same problem and, while I could not find conclusive evidence to this, concluded that it is simply not possible. This is reinforced by the fact that Salesforce doesn't right-align neither their number/date fields nor their titles on the standard listviews (see image).

Short of convoluted CSS (which I wouldn't recommend as it can easily break with upgrades) I don't see how you could do this natively.

Campaigns sample image

PS: I would normally put this as a comment since it is not great as an answer. But I have an image that I want to convey so an answer it is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.