Skip to main content
Tweeted twitter.com/StackSalesforce/status/1335962317947858944
added 572 characters in body
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

How to make buttons in a lightning-datatable smaller in LWC?

I have a lightning-datatable in my componentLightning Web Component (LWC) that has several buttons in each row (first button only shown here):

How to make buttons in a lightning-datatable smaller?

I have a lightning-datatable in my component that has several buttons in each row (first button only shown here):

How to make buttons in a lightning-datatable smaller in LWC?

I have a lightning-datatable in my Lightning Web Component (LWC) that has several buttons in each row (first button only shown here):

added 572 characters in body
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

PPS

Some progress. Manually editing in Chrome this doesn't scale the button:

<lightning-button style="transform: scale(0.75)">
    <button name="viewDetails" title="View Details" type="button"
        class="slds-button slds-button_brand">View Details</button>
</lightning-button>

but this does scale the button:

<lightning-button>
    <button style="transform: scale(0.75)"
        name="viewDetails" title="View Details" type="button"
        class="slds-button slds-button_brand">View Details</button>
</lightning-button>

Unfortunately this CSS selector doesn't work:

.scaled-down button {
    transform: scale(0.75);
}

PPS

Some progress. Manually editing in Chrome this doesn't scale the button:

<lightning-button style="transform: scale(0.75)">
    <button name="viewDetails" title="View Details" type="button"
        class="slds-button slds-button_brand">View Details</button>
</lightning-button>

but this does scale the button:

<lightning-button>
    <button style="transform: scale(0.75)"
        name="viewDetails" title="View Details" type="button"
        class="slds-button slds-button_brand">View Details</button>
</lightning-button>

Unfortunately this CSS selector doesn't work:

.scaled-down button {
    transform: scale(0.75);
}
added 878 characters in body
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

PS

The current .css file in my component contains:

.scaled-down {
    transform: scale(0.75);
}

and my component contains:

        <lightning-datatable
                class="slds-table_striped"
                key-field="Id"
                data={claims}
                columns={columns}
                hide-checkbox-column
                >
        </lightning-datatable>

and an example button column definition is:

const columns = [
    {
        type: "button",
        fixedWidth: 150,
        typeAttributes: {
            label: 'View Details',
            title: 'View Details',
            name: 'viewDetails',
            value: 'viewDetails',
            variant: 'brand',
            class: 'scaled-down'
        }
    },

And the output using "Inspect" in Chrome is:

<lightning-button class="scaled-down">
    <button name="viewDetails" title="View Details" type="button"
        class="slds-button slds-button_brand">View Details</button>
</lightning-button>

PS

The current .css file in my component contains:

.scaled-down {
    transform: scale(0.75);
}

and my component contains:

        <lightning-datatable
                class="slds-table_striped"
                key-field="Id"
                data={claims}
                columns={columns}
                hide-checkbox-column
                >
        </lightning-datatable>

and an example button column definition is:

const columns = [
    {
        type: "button",
        fixedWidth: 150,
        typeAttributes: {
            label: 'View Details',
            title: 'View Details',
            name: 'viewDetails',
            value: 'viewDetails',
            variant: 'brand',
            class: 'scaled-down'
        }
    },

And the output using "Inspect" in Chrome is:

<lightning-button class="scaled-down">
    <button name="viewDetails" title="View Details" type="button"
        class="slds-button slds-button_brand">View Details</button>
</lightning-button>
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458
Loading