You can't get exactly the width of the parent component, but you can know the region's width exposing a @api flexipageRegionWidth
property, that will hold the following values:
SMALL
- if the width is less than 50% - I.E. Left or Right sidebar region (region 2 of your screenshot)
MEDIUM
- if the width greater or equal 50% and less than 100% - I.E. both regions of Header and Two Equal Regions (region 1 of your screenshot)
LARGE
- if the width is 100% - I.E. any region of Header and One Region and One Region template or header region of Header and Left (or Right) Sidebar or Header. (region 3 of your screenshot)
XLARGE
- Header region Header and Two Equal Regions
The latter isn't listed in the documentation, so I wouldn't rely on it.
You could use that value as CSS class of the main container in your HTML template, then define multiple styles in the CSS file, or you could expose several getters to show/hide part of the component, i.e.
get smallRegion() {
return 'SMALL' === this.flexipageRegionWidth;
}
<template if:false={smallRegion}>
<!-- something -->
</template>